import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:h_flutter_119/ext/get_extension.dart';
import 'package:h_flutter_119/res/colors.dart';
import 'package:h_flutter_119/res/style.dart';
import 'package:h_flutter_119/route/route_utils.dart';

class MinePage extends StatelessWidget {
  MinePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: [
          Stack(
            alignment: Alignment.center,
            children: [
              Image.asset(
                'lib/res/assets/mine_bg.png',
                fit: BoxFit.cover,
                height: 500.w,
              ),
              Column(
                children: [
                  ClipOval(
                    child: Image.asset('lib/res/assets/a.jpg',
                        width: 150.w, height: 150.w, fit: BoxFit.cover),
                  ),
                  Box.hBox20,
                  Text('HFlutter',
                      style: TextStyle(fontSize: 32.sp, color: Colors.white))
                ],
              )
            ],
          ),
          InkWell(
            onTap: () {
              showDialog(
                  context: context,
                  builder: (context) {
                    return AlertDialog(
                      title: Text('提示'),
                      content: Text('来都来了，看看呗'),
                      actions: [
                        TextButton(
                            onPressed: () {
                              goWeb(
                                  context, 'https://gitee.com/htgogo/hflutter');
                            },
                            child: Text('确定'))
                      ],
                    );
                  });
            },
            child:_createListTile('关于', "项目地址：https://gitee.com/htgogo/hflutter", Icons.ac_unit),
          ),
          InkWell(
            onTap: () {
              Get.showCommonDialog(
                  title: "GetX框架提示",
                  content: "当前主题是${Get.isDarkMode?"'黑夜‘":"‘白昼’"}\n 是否切换为${Get.isDarkMode?"'白昼‘":"‘黑夜’"}",
                  posiText: '确定',
                  negaText: '取消',
                  posiTap: () {
                    Get.changeTheme(
                        Get.isDarkMode ? ThemeData.light() : ThemeData.dark());
                  });
            },
            child:
            _createListTile('更换主题', '', Icons.change_circle_sharp),
          )
        ],
      ),
    );
  }

  Widget _createListTile(
    String title,
    String subTitle,
    IconData iconData,
  ) =>
      ListTile(
        minLeadingWidth: 25.w,
          leading: Align(
            widthFactor: 1.0,
            alignment: Alignment.center,
            child: Icon(iconData),
          ),
          title: Text(title,
              style: TextStyle(
                  fontSize: 28.sp,
                  color: Colors.black,
                  fontWeight: FontWeight.bold)),
          subtitle: subTitle.isEmpty?null:Text(
            subTitle,
            style: TextStyle(fontSize: 25.sp, color: ColorStyle.color_999999),
          ));
}
